package net.dgg.dggcloud.core.json;

import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StringSerializer;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import java.math.BigInteger;

/**
 * 自定义序列化mapper
 *
 * @author nature
 * @create 2017-10-30 13:45
 */
public class CustomObjectMapper extends ObjectMapper {

	private static final long serialVersionUID = 1683531771040674386L;


//	@Override
//	public ObjectMapper registerModule(Module module) {
//
//		SimpleModule simpleModule = new SimpleModule();
//		simpleModule.addSerializer(BigInteger.class, ToStringSerializer.instance);
//		simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
//		simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
//
//		return super.registerModule(module).registerModule(simpleModule);
//	}
	public CustomObjectMapper() {
		super();

		//不显示为null的字段
//		this.setSerializationInclusion(JsonInclude.Include.NON_NULL);
		SimpleModule simpleModule = new SimpleModule();
		simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
		simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
		registerModule(simpleModule);

	}
}